package com.lambkit.module.cms.core.search;

import com.lambkit.common.service.ServiceKit;
import com.lambkit.common.service.ServiceManager;
import com.lambkit.module.cms.core.search.impl.LuceneFileSearcher;
import com.lambkit.module.cms.core.search.impl.LuceneSearcher;

public class SearcherKit {

	public static void initArticleSearcher(Class<? extends ArticleSearcher> searcherClass) {
		ServiceManager.me().mapping(ArticleSearcher.class, searcherClass, null);
	}

	public static void initFileSearcher(Class<? extends FileSearcher> searcherClass) {
		ServiceManager.me().mapping(FileSearcher.class, searcherClass, null);
	}
	
	public static ArticleSearcher articleSearcher() {
		return ServiceKit.inject(ArticleSearcher.class, LuceneSearcher.class);
	}
	
	public static FileSearcher fileSearcher() {
		FileSearcher s = ServiceKit.inject(FileSearcher.class, LuceneFileSearcher.class);
		if(s==null) {
			System.err.println("[SearcherKit] FileSearcher is null");
			s = new LuceneFileSearcher();
		}
		return s;
	}
	
	
}
